Skip to content

Conversation

@Rohit3523
Copy link
Contributor

@Rohit3523 Rohit3523 commented Dec 22, 2025

Proposed changes

This PR fixes an issue where scrolling to the top of a DM or Room chat would get stuck and fail to load older messages.

To fix this, I observed how the web handles message loading and found that it only loads room level messages while excluding thread messages. Thread messages are fetched only when navigating into a thread. I applied the same behavior in the app to ensure consistent pagination and prevent message loading from getting stuck.

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1701

How to test or reproduce

  1. Go to an old room or user dm with whom you chat the most
  2. Scroll to top
  3. Observe

Expected Behaviour

It should load previous messages

Actual Behaviour

It just stuck on top

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Chore
    • Message loading now uses smaller per-batch loads, causing more frequent incremental fetches when entering rooms.
    • Threaded messages are no longer fetched by default, reducing initial clutter in message lists.
    • The "Load more" prompt now appears only when a full batch of messages is returned, making progressive loading more predictable.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

Walkthrough

Removed the COUNT_LIMIT usage in loadMessagesForRoom.ts, replaced comparisons to use COUNT directly, set fetch param showThreadMessages: false, and changed the load-more creation condition to trigger when data.length === COUNT.

Changes

Cohort / File(s) Summary
Load messages batching
app/lib/methods/loadMessagesForRoom.ts
Removed COUNT_LIMIT and replaced checks with direct COUNT comparisons; added showThreadMessages: false to fetch params; load-more/message-continuation now created only when data.length === COUNT.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • diegolmello

Poem

🐇 I hopped through code where limits used to be,
Replaced a giant cap with a nimble COUNT for me.
Threads tucked away, batches trimmed to size,
Older messages may flow — give the scroll another try! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main bugfix: resolving the issue where older messages fail to load when scrolling to the top of a chat.
Linked Issues check ✅ Passed The code changes directly address CORE-1701 by excluding thread messages from room-level pagination (showThreadMessages: false) and adjusting batch processing logic to align with web behavior for reliable older message loading.
Out of Scope Changes check ✅ Passed All changes in loadMessagesForRoom.ts are directly related to fixing message pagination and thread message handling, which are in scope with the linked issue objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch room-fail-to-load-old-messages


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 780be56 and 87643f9.

📒 Files selected for processing (1)
  • app/lib/methods/loadMessagesForRoom.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/lib/methods/loadMessagesForRoom.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 59e873a and 780be56.

📒 Files selected for processing (1)
  • app/lib/methods/loadMessagesForRoom.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ESLint and Test / run-eslint-and-test

@Rohit3523 Rohit3523 changed the title fix: hat fails to load older messages when scrolling to the top fix: chat fails to load older messages when scrolling to the top Dec 22, 2025
import { generateLoadMoreId } from './helpers/generateLoadMoreId';

const COUNT = 50;
const COUNT_LIMIT = COUNT * 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've done this for a reason…
A few months ago, we had an issue with large threads being used as the last message.
If you test a thread with more than 100 replies as the last message in develop and in this branch, you'll see that this change rolls back the fix.

develop your branch
Simulator Screenshot - iPhone 16 - 2025-12-22 at 19 36 54 Simulator Screenshot - iPhone 16 - 2025-12-22 at 19 35 38

We must find a smart way to make it work without overloading in long-thread cases, if you want we can try to find a solution together on DM.

@Rohit3523 Rohit3523 marked this pull request as draft December 30, 2025 20:24
@Rohit3523 Rohit3523 temporarily deployed to approve_e2e_testing January 11, 2026 20:50 — with GitHub Actions Inactive
@Rohit3523 Rohit3523 had a problem deploying to official_android_build January 11, 2026 20:52 — with GitHub Actions Error
@Rohit3523 Rohit3523 temporarily deployed to experimental_ios_build January 11, 2026 20:52 — with GitHub Actions Inactive
@Rohit3523 Rohit3523 temporarily deployed to experimental_android_build January 11, 2026 20:52 — with GitHub Actions Inactive
@Rohit3523 Rohit3523 had a problem deploying to upload_experimental_android January 11, 2026 21:22 — with GitHub Actions Error
@github-actions
Copy link

Android Build Available

Rocket.Chat Experimental 4.69.0.108033

Internal App Sharing: https://play.google.com/apps/test/RQVpXLytHNc/ahAO29uNTMn9vAH5bv36c_nUXlxopRYNCViAP4C0siFgZb8Ka-PDBpZa0PW3tjssnWCtTL5VEF1zlDncpoeeWWeclS

@github-actions
Copy link

iOS Build Available

Rocket.Chat Experimental 4.69.0.108129

@Rohit3523 Rohit3523 marked this pull request as ready for review January 13, 2026 18:05
@Rohit3523 Rohit3523 had a problem deploying to official_android_build January 13, 2026 20:36 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to upload_experimental_android January 13, 2026 20:36 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to official_android_build January 13, 2026 21:36 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to upload_experimental_android January 13, 2026 21:36 — with GitHub Actions Error
Copy link
Contributor

@OtavioStasiak OtavioStasiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Great job!

@Rohit3523 Rohit3523 requested a deployment to approve_e2e_testing January 16, 2026 07:40 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to official_android_build January 16, 2026 07:43 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to experimental_android_build January 16, 2026 07:43 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to experimental_ios_build January 16, 2026 07:43 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 merged commit 508b720 into develop Jan 16, 2026
5 of 10 checks passed
@Rohit3523 Rohit3523 deleted the room-fail-to-load-old-messages branch January 16, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants